#ifndef SAFEDESTROY_H
#define SAFEDESTROY_H

namespace boost {

/// boost::intrusive_ptr reference counting mechanism for COM objects
inline void intrusive_ptr_add_ref(IUnknown* p)
{
	p->AddRef();
}

/// boost::intrusive_ptr reference counting mechanism for COM objects
inline void intrusive_ptr_release(IUnknown* p)
{
	p->Release();
}

} // namespace

namespace Cvekas {

/// Helper method to safely release COM object pointed by boost::intrusive_ptr
inline void intrusivePtrRelease(boost::intrusive_ptr<IUnknown> p)
{
	if(bool(p)) 
		p->Release();
	p = NULL;
}

/// Helper method to safely release COM object
inline void safeRelease(IUnknown* p)
{
	if(p) 
		p->Release();
	p = NULL;
}

} // namespace

#endif